package com.bardsoftware.foronuvolo.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;

public class DiscussionsViewUI implements EntryPoint {

    private final StartDiscussionServiceAsync myStartDiscussionService = GWT.create(StartDiscussionService.class);
    private MessageSender myMessageSender;

    public void onModuleLoad() {
        if (RootPanel.get("new_message_input") != null) {
            myMessageSender = new MessageSender(
                    RootPanel.get("new_message_input"),
                    RootPanel.get("send_button"),
                    RootPanel.get("preview"),
                    myStartDiscussionService,
                    "new_message_output",
                    "new_message_output") {
                protected void onSuccess(String result) {
                    Window.Location.assign(ForoNuvoloConstants.FORUM_LANDING_PATH);
                }
                protected void onFailure(Throwable caught) {
                    showErrorNotifier("err_notifier");
                }
            };
        }
    }

}
